package com.chengyu.core.controller.shop;

import com.chengyu.core.component.OperationLog;
import com.chengyu.core.controller.UserBaseController;
import com.chengyu.core.domain.CommonConstant;
import com.chengyu.core.entity.CommonResult;
import com.chengyu.core.exception.CommonException;
import com.chengyu.core.exception.ServiceException;
import com.chengyu.core.model.UmsShop;
import com.chengyu.core.model.UmsShopAccount;
import com.chengyu.core.model.UmsShopCate;
import com.chengyu.core.service.order.OrderWriteOffService;
import com.chengyu.core.service.shop.ShopAccountService;
import com.chengyu.core.service.shop.ShopCateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Api(tags = "店铺订单")
@Controller
@RequestMapping("/shop/order")
public class ShopOrderController extends UserBaseController {

	@Autowired
	private ShopCateService shopCateService;

	@Autowired
	private OrderWriteOffService writeOffService;


	@Autowired
	protected ShopAccountService shopAccountService;



//	@ApiOperation(value = "商品详情")
//	@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
//	@ApiImplicitParam(name = "type", value = "商品类型:normal=普通商品,video=视频号商品,seckill=秒杀商品", defaultValue = "normal")
//	public CommonResult<ProductDetailResponse> getDetail(@Validated @PathVariable Integer id,
//														 @RequestParam(value = "type", required = false) String type) {
//		return CommonResult.success(productService.getDetail(id, type));
//	}





//	@OperationLog
//	@ApiOperation(value = "detail")
//	@ResponseBody
//	@RequestMapping(value="/detail", method=RequestMethod.GET)
//	public CommonResult<UmsShopCate> detail(Integer id) throws ServiceException {
//
//		UmsShopCate  shopCate  =shopCateService.getShopCateById(id);
//		return CommonResult.success(shopCate);
//	}


//	@ResponseBody
//	@RequestMapping(value={"/setNickname"}, method=RequestMethod.POST)
//	public CommonResult<String> setNickname(String username,String cToken, String captcha, String code) throws Exception {
//
//
//	}
//	@OperationLog
//	@ApiOperation(value = "设置订单备注")
//	@ResponseBody
//	@RequestMapping(value="/setRemark", method=RequestMethod.POST)
//	public CommonResult<String> setRemark(String remark) throws ServiceException {
//
////		System.out.println("cate.getType();"+cate.getType());
//		if (cate.getType() == null || cate.getType().equals(0)){
//			cate.setType(1);
//		}
//
////		System.out.println("submitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmitsubmit");
////		System.out.println(cate);
//
//		if(cate.getId() == null){
//			shopCateService.addShopCate(getCurrentShop(), cate.getPid(), cate.getName(), cate.getSort(), cate.getImg(), cate.getType());
//		}else {
//			shopCateService.updateShopCate(cate);
//		}
//		return CommonResult.success(null);
//	}





//	@ApiOperation(value = "删除")
//	@OperationLog
//	@ResponseBody
//	@RequestMapping(value = {"/del"}, method = RequestMethod.POST)
//	public CommonResult<String> del(@RequestBody Map<String, String> json) throws CommonException, ServiceException {
//		String ids = json.get("ids");
//		System.out.println("ids{}"+ids);
//		if(StringUtils.isEmpty(ids)) {
//			return CommonResult.failed( "请至少选择一条数据");
//		}
//		for(String id : ids.split(CommonConstant.DH_REGEX)){
//			System.out.println("id{}"+id);
//			shopCateService.deleteShopCate(Integer.valueOf(id));
//		}
//		return CommonResult.success(null);
//	}


}
